add the possibility to distinct format_n type from the others
authorMichael Muré <batolettre@gmail.com>
Fri, 19 Aug 2011 20:32:07 +0000 (22:32 +0200)
committerMichael Muré <batolettre@gmail.com>
Fri, 19 Aug 2011 20:32:07 +0000 (22:32 +0200)
babl/babl-format.c
babl/babl-format.h
babl/babl.h

index af7af69354ad9939e7e67f9295ec47010de0cadc..463a92bc1a7f468819d29a72246c2c3e237ed5e2 100644 (file)
@@ -112,6 +112,7 @@ format_new (const char     *name,
   babl->format.loss = -1.0;
   babl->format.visited = 0;
   babl->format.image_template = NULL;
+  babl->format.format_n = 0;
 
   return babl;
 }
@@ -195,6 +196,15 @@ ncomponents_create_name (Babl *type,
   return babl_strdup (buf);
 }
 
+static void
+babl_format_set_is_format_n (Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      format->format.format_n = 1;
+    }
+}
+
 Babl *
 babl_format_n (Babl *btype,
                int   components)
@@ -232,11 +242,25 @@ babl_format_n (Babl *btype,
                      planar, components, model,
                      component, sampling, type);
 
+  babl_format_set_is_format_n (babl);
+
   babl_db_insert (db, babl);
   babl_free (name);
   return babl;
 }
 
+int
+babl_format_is_format_n (Babl *format)
+{
+  if (format->class_type == BABL_FORMAT)
+    {
+      return format->format.format_n;
+    }
+
+  return 0;
+}
+
+
 static int
 is_format_duplicate (Babl           *babl,
                      int             planar,
index fb8dfac1087890ff3dff398b027baf5af4068ccd..68fc87d0e62466abb1df015be9de6b273e93103a 100644 (file)
@@ -39,6 +39,7 @@ typedef struct
                              from and to RGBA double */
   int              visited; /* for convenience in code while searching
                                for conversion paths */
+  int              format_n; /* whether the format is a format_n type or not */
 } BablFormat;
 
 #endif
index cddfbb7f468bb58e39d8503a614780151b04aa75..2c248a5b3e20f43e97451a93ef2c843e838c1b79 100644 (file)
@@ -182,6 +182,11 @@ Babl *
 babl_format_n (Babl *type,
                int   components);
 
+/**
+ * Returns whether the @format is a format_n type.
+ */
+int babl_format_is_format_n (Babl *format);
+
 /**
  * Defines a new conversion between either two formats, two models or
  * two types in babl.